package hibernate.administratorAccount;

import java.util.*;

public class Mapping implements java.io.Serializable{
	
	public static class MappingType{
		
		private static MappingType enabled=new MappingType("enabled");
		private static MappingType invisible=new MappingType("invisible");
		private static MappingType disabled=new MappingType("disabled");
		
		private String name;
		
		private MappingType(String n){
			this.name=n;
		}
		
		public String toString(){
			return name;
		}
		
		public static MappingType getEnabled(){return enabled;} 
		public static MappingType getInvisible(){return invisible;}
		public static MappingType getDisabled(){return disabled;}
	}
	
	private String appName;
	private Long id;
	private Map commandMapping;
	private Employee employee;
	
	public void setAppName(String name){this.appName=name;}
	
	public String getAppName(){return appName;}
	
	public void setId(Long id){this.id=id;}
	
	public Long getId(){return id;}
	
	public void setEmployee(Employee employee){
		this.employee=employee;
	}
	
	public Employee getEmployee(){return employee;}
	
	public void putInCommandMapping(String s,MappingType m){
		commandMapping.put(s, m.toString());
	}
	
	public void setCommandMapping(Map commandMapping){
		this.commandMapping=commandMapping;
	}
	
	public Map getCommandMapping(){
		return commandMapping;
	}
	
	public Map getTransformedMap(){
		Map ret=new HashMap();
		if(commandMapping != null){
			Iterator nameItr=commandMapping.keySet().iterator();
			String tempName;
			while(nameItr.hasNext()){
				tempName=nameItr.next().toString();
				String str=commandMapping.get(tempName).toString();
				if(str.equals("enabled"))
					ret.put(tempName, MappingType.getEnabled());
				else if(str.equals("disabled"))
					ret.put(tempName, MappingType.getDisabled());
				else ret.put(tempName, MappingType.getInvisible());
			}
		}
		return ret;
	}
	
	public boolean equals(Object obj){
		if(!(obj instanceof Mapping))
			return false;
		else return ((Mapping)obj).employee.equals(this.employee) && ((Mapping)obj).appName.equals(this.appName);
	}
	
	public String toString(){
		return this.appName;
	}
}
